﻿Imports System.Web.UI
Imports System.ComponentModel

Namespace Controls
    <ToolboxItem(False), PersistChildren(True), ParseChildren(False)> _
    Public Class TabPage
        Inherits WebControl
        Implements INamingContainer
        Private _ClientID As String

        Public Sub New()
            Me._Selected = False
            Me._Caption = String.Empty
            Me._ClientID = String.Empty
            Me._ActionLink = String.Empty
        End Sub

        Public Function GetTabControl() As Object
            Return Me._tabControl
        End Function

        Protected Overloads Overrides Sub Render(ByVal pOutPut As HtmlTextWriter)
            If (Me._tabControl Is Nothing) OrElse (Me._tabControl.[GetType]().ToString() <> "LSW.Web.Controls.TabControl") Then
                Throw New ArgumentException("LSW.Web.Controls.TabPage 必须是 LSW.Web.Controls.TabControl 的子控件")
            End If
            If Me.Selected Then
                pOutPut.Write(String.Concat(New Object() {"<div id=""", Me.UniqueID, """ class=""tab-page"" style=""display: block;background: #fff;"">"}))
            Else
                pOutPut.Write(String.Concat(New Object() {"<div id=""", Me.UniqueID, """ class=""tab-page"" style=""display: none;background: #fff;"">"}))
            End If

            Me.RenderChildren(pOutPut)
            pOutPut.Write("</div>")
        End Sub

        Friend Sub RenderDownLevelContent(ByVal pOutPut As HtmlTextWriter)
            Me.Render(pOutPut)
        End Sub


        Private _tabControl As TabControl
        Friend Sub SetTabControl(ByVal pTabControl As TabControl)
            Me._tabControl = pTabControl
        End Sub

        Private _ActionLink As String
        <NotifyParentProperty(True), Browsable(True), Description("")> _
        Private Property ActionLink() As String
            Get
                Return Me._ActionLink
            End Get
            Set(ByVal value As String)
                Me._ActionLink = value
            End Set
        End Property

        Private _Caption As String
        <NotifyParentProperty(True), Description(""), Browsable(True)> _
        Public Property Caption() As String
            Get
                Return Me._Caption
            End Get
            Set(ByVal value As String)
                Me._Caption = value
            End Set
        End Property

        Private _Selected As Boolean
        Friend Property Selected() As Boolean
            Get
                Return Me._Selected
            End Get
            Set(ByVal value As Boolean)
                Me._Selected = value
            End Set
        End Property
    End Class
End Namespace